/*
 *Program Name: SharedFunctions.cpp
 *Written By:   Cheng-Hsiu Hsieh
 */
#include <Windows.h>
#include "SharedFunctions.h"

int RandomNumber( bool NegativeNumber , int range )
{
  if ( NegativeNumber )
    if ( GetTickCount() % 2 ) //if even then positive
      return ( GetTickCount() * 7 % range );
    else                      //else negative
      return ( 0 - GetTickCount() * 7 % range );
  else
    return ( GetTickCount() * 7 % range );
}

int RandomX( int range )
{
  static DWORD iPrev = GetTickCount();
  int iResult;
  if ( iPrev % 2 )
    iResult = ( iPrev * 7 ) % range;
  else
    iResult = 0 - ( iPrev * 7 ) % range;
  iPrev = iResult;
  return iResult;
}

int RandomY( int range )
{
  static DWORD iPrev = GetTickCount();
  int iResult;
  if ( iPrev % 2 )
    iResult = ( iPrev * 7 ) % range;
  else
    iResult = 0 - ( iPrev * 7 ) % range;
  iPrev = iResult;
  return iResult;
}